///@file Mesh.h
///@brief Declaration of the class representing a Finite Element mesh
///@author Arnaud Duval
///@version 0.0
///@date 2010/02/26


#ifndef MESH_H
#define MESH_H

#include <assert.h>
#include <iostream>
#include <list>

#include "../../mathobject/include/Vector.h"
#include "../../mathobject/include/Matrix.h"
#include "Node.h"
#include "Element.h"
#include "Truss2.h"
#include "Quad4.h"
#include "Material.h"
#include "ElasticMaterial.h"
#ifdef ENABLE_LIBXMLPP
#include <libxml++/libxml++.h>
#endif

///@class Mesh
///@brief Class defining a finite element mesh
class Mesh
{
	private:
		///@brief List of nodes
		std::list<Node> nodes;
		///@brief List of materials
		std::list<Material*> materials;
		///@brief List of elements
		std::list<Element*> elements;
	public:
		///@brief Default constructor
		Mesh();
        ///@brief Copy constructor
        Mesh(const Mesh&);
		///@brief destructor
		~Mesh();
        ///@brief Overload of = operator
        Mesh& operator=(const Mesh);

		#ifdef ENABLE_LIBXMLPP
		///@brief Read mesh definition from xml file
		void ReadXML(std::string);
		///@brief Read the nodes list from a XML node
		void ReadNodeListFromXMLNode(xmlpp::Node*);
		///@brief Read the materials list from a XML node
		void ReadMaterialListFromXMLNode(xmlpp::Node*);
		///@brief Read the elements list from a XML nodes
		void ReadElementListFromXMLNode(xmlpp::Node*);
		#endif
		///@brief Compute stiffness matrix
		void Equilibrate();
        ///@brief Return true if the given node exists
        bool NodeExists(std::string);
        ///@brief Return a pointer to a given node
        Node* GetPointerToNode(std::string);

		///@brief Overload of << operator
		friend std::ostream& operator<<(std::ostream&, Mesh&);


};

#endif